//
//  UserService.m
//  tristana
//
//  Created by bug neo on 05/01/2021.
//  Copyright © 2021 李康. All rights reserved.
//

#import "UserService.h"

@implementation UserService
+ (void)saveUserBean:(UserBean *)bean{
    
    NSDictionary *userDic = [bean toDictionary];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:userDic forKey:@"ACCESSED_USER"];
    [defaults synchronize];//同步到 记录中
}
+ (void)deleteUserBean {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults removeObjectForKey:@"ACCESSED_USER"];
    [defaults synchronize];//同步到 记录中
}
+ (BOOL)isLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *dic = [defaults objectForKey:@"ACCESSED_USER"];
    if ([[dic valueForKey:@"phone"] length]) {
        return YES;
    }
    return NO;
    
}

+ (UserBean *)getUserBean {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *dic = [defaults objectForKey:@"ACCESSED_USER"];
    UserBean *bean = [[UserBean alloc] initWithDictionary:dic error:nil];
    return bean;
}
@end
